package com.ssm.dao;

import com.ssm.domain.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author: my_code
 * @Description: TODO
 * @Date: Create in 15:17 2020/8/21
 */
public interface IProductDao {

    /**
     * @return:
     * @Description: 查询所有的产品信息
     * @param:
     */
    @Select("select * from product")
    List<Product> findAll() throws Exception;

    /**
     * @return:
     * @Description: 添加产品信息
     * @param:
     */
    @Insert("insert into product(productNum, productName, cityName, departureTime, productPrice, productDesc, productStatus) values(#{productNum} , #{productName}, #{cityName}, #{departureTime}, #{productPrice}, #{productDesc}, #{productStatus})")
    void save(Product product) throws Exception;

    /**
     * @return:
     * @Description: 根据id删除产品信息
     * @param: [id]
     */
    @Delete("delete from product where id = #{id}")
    void deleteById(String id) throws Exception;

    /**
     * @return:
     * @Description: 根据Id查询产品信息
     * @param: [id]
     */
    @Select("select * from product where id = #{id}")
    Product findById(String id) throws Exception;
}
